package com.ruirenyun.config.filter;

import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.web.servlet.FilterRegistrationBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import javax.sql.DataSource;

/**
 * @author Deng Ye
 */
@Configuration
public class FilterConfig {
    public static final Logger log = LogManager.getLogger(FilterConfig.class);

    @Value("${login.notCheckUrlList}")
    String notCheckLoginUrlList;
    @Value("${login.checkKey}")
    String checkKey;

    @Autowired
    DataSource dataSource;

    /**
     * 登录过滤器
     */
    /*@Bean
    public FilterRegistrationBean<CheckLoginFilter> loginFilterRegistration() {
        FilterRegistrationBean<CheckLoginFilter> registration = new FilterRegistrationBean<>(new CheckLoginFilter());
        registration.addInitParameter("notCheckLoginUrlList", notCheckLoginUrlList);
        registration.addInitParameter("checkKey", checkKey);
        registration.setOrder(1);
        return registration;
    }*/

    /**
     * 响应头处理过滤器
     */
    @Bean
    public FilterRegistrationBean<RequestFilter> requestFilterRegistration() {
        FilterRegistrationBean<RequestFilter> registration = new FilterRegistrationBean<>(new RequestFilter());
        registration.setOrder(3);

        return registration;
    }

}
